function validateSolutionNewForm(form){
    var errorList = new Array();

    var solution = form['solution'].value;
    var description = form['description'].value;
    var src = form['file'].value;
    var extensions = form['extensions'].value;
    
    if (!solution) {
        errorList.push('Empty solution');
        fieldHighlight(form['solution'], true);
    }
    if (!description) {
        errorList.push('Empty description');
        fieldHighlight(form['description'], true);
    }
   
    if (src != "") {
        var format = src.substring(src.length - 3);
        var expresionsArray = extensions.split(", ");
        var allowed = false;
        for (var i = 0; i < expresionsArray.length; i++) 
        {
            if (expresionsArray[i] == format) {
                allowed = true;
                break;
            }
        }
        if (!allowed)
            errorList.push('Only ' + extensions + ' file extensions are accepted for upload');
    }
    
    if (errorList.length > 0) {
        showErrorList(errorList);
        return false;
    } else {
        return true;
    }
}
function set_vote(widget, vote) {
    $(widget).find('.star_' + vote).prevAll().andSelf().addClass('ratings_vote');
    $(widget).find('.star_' + vote).nextAll().removeClass('ratings_vote'); 
}

function star_clicked(star){
    var widget = $(star).parent();
    var rateId = $(star).attr('id');
    $(widget).attr('disabled', 'disabled');
    var clicked_data = {
        rate : rateId.substr(rateId.length - 1, 1),
        solution : $(star).parent().attr('id').split('-')[1]
    };
    $.post(
        'rate.php',
        clicked_data,
        function(data) {
            set_vote(widget, data.result);
            $(widget).removeAttr('disabled');
        },
        'json'
        ); 
}

function star_hover_in(star){
    $(star).prevAll().andSelf().addClass('ratings_over');
}

function star_hover_out(star){
    $(star).prevAll().andSelf().removeClass('ratings_over');
}